﻿using Dora.Tools.Enums.AdminUser;
using System;
using System.Collections.Generic;

namespace Dora.Tools.Utility.Models
{
    public class IdentityUserDto
    {
        public IdentityUserDto()
        {
            AuthKeyList = new List<AuthKeyItem>();
            OrgList = new List<OrgDto>();
        }
        #region 通用
        public Guid Id { get; set; }

        public string UserName { get; set; }

        public string RealName { get; set; }

        public string NickName { get; set; }

        public string Mobile { get; set; }

        /// <summary>
        /// 手机号是否验证
        /// </summary>
        public bool MobileIsVerified { get; set; }

        public int IsSuperAdmin { get; set; }
        
        public  string Avatar { get; set; }
        /// <summary>
        /// 用户所属系统
        /// </summary>
        public string SystemKey { get; set; }
        /// <summary>
        /// 权限列表
        /// </summary>
        public List<AuthKeyItem> AuthKeyList { get; set; }
        /// <summary>
        /// 环信用户名 系统id_短Id
        /// </summary>
        public string HxUserName { get; set; }

        public string ShowName {
            get
            {
                var showName = "";
                if (!string.IsNullOrWhiteSpace(RealName))
                {
                    showName = RealName;
                }
                else
                {
                    //showName = NickName;
                    if (!string.IsNullOrWhiteSpace(NickName))
                    {
                        showName = NickName;
                    }
                    else
                    {
                        showName = UserName;
                    }
                }
                return showName;
            }
        }
        #endregion

        #region TAS

        /// <summary>
        /// 有权限访问的组织机构List
        /// </summary>
        public List<OrgDto> OrgList { get; set; }
                
        /// <summary>
        /// 最后访问的组织机构
        /// </summary>
        public LastOrgDto LastOrg { get; set; }
        #endregion

        #region SRM
        /// <summary>
        /// 供应商
        /// </summary>
        public SupplierDto Supplier { get; set; }
        #endregion

        #region TasMP
        /// <summary>
        /// 供应商
        /// </summary>
        public MPUserDto MPUser { get; set; }
        #endregion
    }

    public class AuthKeyItem
    {
        public string AuthKey { get; set; }
        public string Name { get; set; }
        public string Icon { get; set; }
        public int Sort { get; set; }
    }

    public class OrgDto
    {
        public int Id { get; set; }
        public string Name { get; set; }
        /// <summary>
        /// 层级路径;从最祖宗到本级,英文逗号分隔
        /// </summary>
        public string LevelPath { get; set; }
    }
    /// <summary>
    /// Tas系统 最后登录组织机构信息
    /// </summary>
    public class LastOrgDto
    {
        public int Id { get; set; }

        /// <summary>
        /// 组织机构名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 机构级别;组织机构级别 0：总（大）社，1：分社，2：门店，3：直属门店，4：直属部门。
        /// </summary>
        public int? OrgLevel { get; set; }

        /// <summary>
        /// 层级路径;从最祖宗到本级,英文逗号分隔
        /// </summary>
        public string LevelPath { get; set; }

        /// <summary>
        /// 上一级机构Id
        /// </summary>
        public int ParentOrgId { get; set; }

        /// <summary>
        /// 顶级机构Id
        /// </summary>
        public int RootId { get; set; }

        /// <summary>
        /// 组织机构权限类型
        /// </summary>
        public PermissionOrgType PermissionOrgType { get; set; }
        
        /// <summary>
        /// 纳税类型
        /// </summary>
        public int TaxPaymentType { get; set; }

        /// <summary>
        /// 是否允许签约供应商
        /// </summary>
        public AllowContractSupplier IsAllowContractSupplier { get; set; }

        /// <summary>
        /// 【分社】是否允许更换保险 字段含义变更：30:不允许更换保险，31:允许更换保险
        /// </summary>
        public AllowContractInsuranceSupplier IsContractInsuranceSupplier { get; set; }

        /// <summary>
        /// 【分社】是否允许独立结算;60:不允许，61:允许
        /// </summary>
        public AllowSettlementBySelf IsAllowSettlementBySelf { get; set; }

        /// <summary>
        /// 是否允许开设门店
        /// </summary>
        public AllowAllowOpenStores IsAllowOpenStores { get; set; }

        /// <summary>
        /// 门店是否需要审批
        /// </summary>
        public short IsAllowAudit { get; set; }

        /// <summary>
        /// 层级路径IdList 从最祖宗到本级
        /// </summary>
        public List<int> PathIdList { get; set; }

        /// <summary>
        /// 是否在组织机构冻结
        /// </summary>
        public short IsFrozen { get; set; }

        /// <summary>
        /// 是否是所在机构负责人
        /// </summary>
        public int IsLeader { get; set; }

        /// <summary>
        /// 门店是否编辑出团通知书;0:否，1:是
        /// </summary>
        public short IsNeedStoreEdit { get; set; }

        /// <summary>
        /// 【总社】是否需要纸质合同;0:否，1:是
        /// </summary>
        public short IsNeedPaperContract { get; set; }

        /// <summary>
        /// 是否需要编辑出团通知书
        /// </summary>
        public bool IsEditDepartureNotice { get; set; }

        /// <summary>
        /// 工号
        /// </summary>
        public string JobNumber { get; set; }
    }

    /// <summary>
    /// Srm系统 供应商信息
    /// </summary>
    public class SupplierDto
    {
        public int Id { get; set; }

        /// <summary>
        /// 供应商名称
        /// </summary>
        public string Name { get; set; }

    }

    /// <summary>
    /// 小程序用户扩展信息
    /// </summary>
    public class MPUserDto
    {
        /// <summary>
        /// 绑定旅游顾问所属的门店的大社
        /// </summary>
        public int TopOrgId { get; set; }
        /// <summary>
        /// 绑定旅游顾问所属的门店
        /// </summary>
        public int BelongOrgId { get; set; }

        /// <summary>
        /// 绑定旅游顾问所属的门店名称
        /// </summary>
        public string BelongOrgName { get; set; }

        /// <summary>
        /// 旅游顾问Id
        /// </summary>
        public Guid SaleUserId { get; set; }

        /// <summary>
        /// 旅游顾问名字
        /// </summary>
        public string SaleRealName { get; set; }

        /// <summary>
        /// 旅游顾问环信用户名
        /// </summary>
        public string SaleHxUserName { get; set; }

        /// <summary>
        /// 微信小程序OpenId 
        /// </summary>
        public string WxMPOpenId { get; set; }

        /// <summary>
        /// 微信session_key 
        /// </summary>
        public string WxSessionKey { get; set; }
    }
}
